﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;

namespace Pc_Vision.View_Datalayer
{
    public partial class viewAdminEdit : System.Web.UI.Page
    {
        public void fn_Cancel(object sender, EventArgs e)
        {

            Response.Redirect("Index.aspx");
        }


        public void fn_SearchAdmin(object sender, EventArgs e)
        {
            DAOFactorys.DAOadmin daoAdmin = new DAOFactorys.DAOadmin();
            ArrayList arr = daoAdmin.GetAllAdmin();
            string searchVal = tbUsername.Text;
            foreach (Model.Admin obj in arr)
            {
                if (obj.username == searchVal)
                {
                    tbPassword.Text = obj.password;
                    tbId.Text = obj.id;
                }    
            }
        }


        public void fn_EditAdmin(object sender, EventArgs e)
        {
            DAOFactorys.DAOadmin da = new DAOFactorys.DAOadmin();
            Model.Admin a = new Model.Admin();
            a.username = tbUsername.Text;
            a.password = tbPassword.Text;
            a.id = tbId.Text;
            da.UpdateAdmin(a);
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}